import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

// 解决重复点击一个路由时的报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace(location) {
    return originalReplace.call(this, location).catch(err => err)
}




const routes = [{
        path: '/',
        redirect: '/home'
    },
    // 首页
    {
        path: '/home',
        name: 'home',
        component: () =>
            import ('../views/Home/Home'),
        children: [{
            path: '/home/more',
            component: () =>
                import ('../views/Home/More'),
        }]
    },
    // 认证题库
    {
        path: '/problems',
        name: 'problems',
        component: () =>
            import ('../views/Problems/Problems'),
    },
    {
        path: '/problems/answer',
        name: 'answer',
        component: () =>
            import ('../views/Problems/answer/Answer'),
        children: [{
            path: '/problems/answer/analysis',
            component: () =>
                import ('../views/Problems/answer/Analysis'),
        }]
    },
    {
        path: '/problems/answer/result',
        name: 'result',
        component: () =>
            import ('../views/Problems/answer/Result'),
    },
    // 解决方案
    {
        path: '/solve',
        name: 'solve',
        component: () =>
            import ('../views/Solve/Solve'),
        children: [{
            path: '/solve/tips',
            component: () =>
                import ('../views/Solve/Tips'),
        }, ]
    },
    {
        path: '/assessment',
        name: 'assessment',
        component: () =>
            import ('../views/Solve/assessment/Assessment'),
    },
    {
        path: '/assessment/scrollmain',
        name: 'scrollmain',
        component: () =>
            import ('../views/Solve/assessment/scrollMain'),
    },
    {
        path: '/assessment/start',
        component: () =>
            import ('../views/Solve/assessment/startAssessment'),
    },
    {
        path: '/assessment/assmessment_list',
        name: 'assmessment_list',
        component: () =>
            import ('../views/Solve/assessment/AssessmentList'),
    },
    {
        path: '/solve/addmembers',
        name: 'addmembers',
        component: () =>
            import ('../views/Solve/addmembers/AddMembers'),
    },
    // 动作库
    {
        path: '/action',
        name: 'action',
        component: () =>
            import ('../views/Action/Action'),
    },
    // 我的
    {
        path: '/mine',
        name: 'mine',
        component: () =>
            import ('../views/Mine/Mine'),
    },
    // 我的个人资料
    {
        path: '/edit',
        name: 'edit',
        component: () =>
            import ('../views/Mine/nextdir/Edit'),
    },
    // 我的案例展示
    {
        path: '/classic',
        name: 'classic',
        component: () =>
            import ('../views/Mine/nextdir/Classic'),
    },
    // 我的留言反馈
    {
        path: '/message',
        name: 'message',
        component: () =>
            import ('../views/Mine/nextdir/Message'),
    },


]

const router = new VueRouter({
    routes,
    // mode: 'history'
})

export default router